package message;

public class Test {
	public static void main(String[] args) {
		String temperamentName;
		int choleric=-10,sanguine=1,phlegmatic=7,melancholic=10;
		int[] score={choleric,sanguine,phlegmatic,melancholic};
		String[] temperament={"choleric","sanguine","phlegmatic","melancholic"};
		int time1=0,time2=0;
	    for (int i=0;i<score.length-1;i++) {
	        ++time1;
	        for (int j=i+1;j<score.length;j++) {
	            ++time2;
	            int scor;
	            String temp;
	            if (score[i]<score[j]) {
	            	scor=score[j];
	                score[j]=score[i];
	                score[i]=scor;

	            	temp=temperament[j];
	            	temperament[j]=temperament[i];
	            	temperament[i]=temp;
	            }
	        }
	    }
	    if(score[0]-score[1]>=4)	temperamentName=temperament[0];
	    else if(score[1]-score[2]>=4)	temperamentName=temperament[0]+"+"+temperament[1];
	    else if(score[2]-score[3]>=4)	temperamentName=temperament[0]+"+"+temperament[1]+"+"+temperament[2];
	    else	temperamentName=temperament[0]+"+"+temperament[1]+"+"+temperament[2]+"+"+temperament[3];
	    System.out.println("外循环次数：" + time1 + "内循环次数：" + time2);
	    System.out.println("排序后 " + score[0]+"******"+score[1]+"******"+score[2]+"******"+score[3] + " ");
	    System.out.println("排序后 " + temperamentName);
	}
}